/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vtc.app;

import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.LayerManager;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author Admin
 */
public class EnemySprite extends BaseSprite{

    public int move;
    private int status = 1; // 1= song; 0= chet
    public int mili = 500;
    private Vector arr;
    private LayerManager lm;
    private Timer t;
    public int gocX;
    public int gocY;

    public int getGocX() {
        return gocX;
    }

    public void setGocX(int gocX) {
        this.gocX = gocX;
    }

    public int getGocY() {
        return gocY;
    }

    public void setGocY(int gocY) {
        this.gocY = gocY;
    }
    
    public EnemySprite(Image image, int frameWidth, int frameHeight, int speed,Vector arr,LayerManager lm) {
        super(image, frameWidth, frameHeight, speed);
        this.arr = arr;
        this.lm  = lm;
        
    }
    
    private void removeSprite(){
        if(status==0){
            arr.removeElement(this);
            lm.remove(this);
            t.cancel();
            t=null;
        }
    }
    public void die(){
        this.status = 0;
        t = new  Timer();
        TimerTask tt = new TimerTask(){
            public void run() {
                removeSprite();
            }            
        };       
        t.schedule(tt,mili);
    }
}
